<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8">
  <title>layui</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <link rel="stylesheet" href="__PUBLIC__/layui/css/layui.css"  media="all">
  <link rel="stylesheet" href="__PUBLIC__/font-awesome/css/font-awesome.min.css" media="all" />
  <link rel="stylesheet" href="__CSS__/admin.css"  media="all">
  <style type="text/css">

/* tooltip */
#tooltip{
  position:absolute;
  border:1px solid #ccc;
  background:#333;
  padding:2px;
  display:none;
  color:#fff;
}
</style>
</head>
<body style="padding:10px;">
  <div class="tplay-body-div">
    <div class="layui-tab">
      <ul class="layui-tab-title">
        <li class="layui-this">收益明细</li>
      </ul>
    </div>
    <table class="layui-table" lay-size="sm">
      <thead>
        <tr>
          <th>编号</th><th>收益人</th><th>返利商品</th><th>返利金额</th><th>分成类型</th><th>入账状态</th><th>创建时间</th><th>操作</th></tr>
      </thead>
      <tbody>
        {volist name="admin" id="vo" key="key"}
        <tr>
          <td>{$key}</td>
          <td>{$vo.username}</td>
          <td>{$vo.goods_name}</td>
          <td>{$vo.money}</td>
          <td>
            {if condition="$vo.type eq 1 "}
            <button class="layui-btn layui-btn-primary layui-btn-sm">用户分成</button>
            {elseif condition="$vo.type eq 2"}
            <button class="layui-btn layui-btn layui-btn-sm">代理收益</button>
            {elseif condition="$vo.type eq 3"}
            <button class="layui-btn layui-btn-warm layui-btn-sm">代理分成</button>
            {/if}
          </td>
          <td>
            {if condition="$vo.status eq 1 "}
            <button class="layui-btn layui-btn-normal layui-btn-sm">待入账</button>
            {elseif condition="$vo.status eq 2"}
            <button class="layui-btn layui-btn-danger layui-btn-sm">已入账</button>
            {/if}
          </td>
          <td>{$vo.create_time}</td>
         <td class="operation-menu">
            <div class="layui-btn-group">
<!--              <a href="{:url('admin/banner/publish',['id'=>$vo.id])}" class="layui-btn layui-btn-sm" style="margin-right: 0;font-size:12px;">编辑</a>-->
<!--              <a href="javascript:;" class="layui-btn layui-btn-danger layui-btn-sm delete" id="{$vo.id}" style="margin-right: 0;font-size:12px;"><i class="layui-icon"></i></a>-->
            </div>
          </td>
        </tr>
        {/volist}
      </tbody>
    </table>
    <div style="padding:0 20px;">{$admin->render()}</div>
    {include file="public/foot"}
    <script type="text/javascript">

    $('.delete').click(function(){
      var id = $(this).attr('id');
      layer.confirm('确定要删除?', function(index) {
        $.ajax({
          url:"{:url('admin/banner/delete')}",
          data:{id:id},
          success:function(res) {
            layer.msg(res.msg);
            if(res.code == 1) {
              setTimeout(function(){
                location.href = res.url;
              },1500)
            }
          }
        })
      })
    })
    </script>
    <script type="text/javascript">

    $('.status').click(function(){
      var val = $(this).attr('data-val');
      var id = $(this).attr('data-id');
      var i = $(this).find('i');
      var the = $(this);
      if(val == 1){
        var status = 0;
      } else {
        var status = 1;
      }
      $.ajax({
        type:"post",
        url:"{:url('admin/banner/status')}",
        data:{status:status,id:id},
        success:function(res){
          
          if(res.code == 1) {
            top();
              layer.msg(res.msg);
          } else {
            layer.msg(res.msg);
          }
        }
      })

      function top(){
        if(val == 1){
          i.attr("class","fa fa-toggle-off");
          the.attr('data-val',0);
        } else {
          i.attr("class","fa fa-toggle-on");
          the.attr('data-val',1);
        }
      }
    })


    </script>
  </div>
</body>
</html>
